package com.hut.oa.model.dao.discuss;


import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.hut.oa.model.bean.Dept;
import com.hut.oa.model.bean.DiscussArea;


public interface DiscussDao extends PagingAndSortingRepository<DiscussArea, Long>{
	//查询讨论和公告的帖子
	@Query("from DiscussArea da where da.type=0")
	Page<DiscussArea> announceDiscussList(Pageable pageable);
	
	@Query("from DiscussArea da where da.type=1")
	Page<DiscussArea> noticeDiscussList(Pageable pageable);
	
	//帖子的评论数加一
	@Query("UPDATE DiscussArea da SET da.commentNum=da.commentNum+1 WHERE da.id=:id")
	@Modifying
	void updateCommentNum(@Param("id")Long id);
	
	//模糊查询帖子标题
	@Query("from DiscussArea da where da.title like %:key%")
	Page<DiscussArea> findByTitle(@Param("key")String key,Pageable pageable);//模糊查询部门信息
	
}
